--[[
    Author          ZhengFeng
    Time            2020.12.08
    Description     宠物申请界面-一键删除
]]--

require "Common/define"
require "Logic/PetManager"
local Page_PetApplyRefuseAll = UIBase.New(PanelResNames.Page_PetApplyRefuseAll)
local this = Page_PetApplyRefuseAll

function this:Init()
    UIBase.Init(this)
end

function this:OnCreate()
    self.Btn_BGClose = self:GetChild("Btn_BGClose")
    self:RegisterOnClick(self.Btn_BGClose, self.onClickClose)
    self.Btn_Cancel = self:GetChild("Btn_Cancel")
    self:RegisterOnClick(self.Btn_Cancel, self.onClickClose)
    self.Txt_PanelTitle = self:GetChild("Txt_PanelTitle")
    self.Txt_PanelTitle.text = getLanguage("PetApply_Confirm")  --"申请核准"
    self.Txt_Content = self:GetChild("Txt_Content")
    self.Txt_Content.text = getLanguage("PetApply_RefuseAll") --"您确认要删除所有的申请吗？"
    self.Btn_Confirm = self:GetChild("Btn_Confirm")
    self:RegisterOnClick(self.Btn_Confirm, self.onClickConfirm)


end

function this:OnEnable()

end

function this:OnDisable()

end
function this:OnDestroy()

end

function this:onClickClose()
    closeUI(PanelResNames.Page_PetApplyRefuseAll)
end

function this:onClickConfirm()
    local _templatePetId = 0
    local _mutatePetId = 0
    for _, applyInfo in ipairs(PetManager.applies) do
        _templatePetId = applyInfo.templatePetInfo.petId
        _mutatePetId = applyInfo.mutatePetInfo.petId
        if _templatePetId and _mutatePetId then
            PetHandler.ReqRefuseMating(_templatePetId, _mutatePetId)
        end
    end
    self:onClickClose()
    PetManager.applies = {}
end

return this